package cn.itsource.user.controller;

import cn.itsource.basic.util.AjaxResult;
import cn.itsource.user.domain.LoginInfo;
import cn.itsource.user.service.ILoginInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/login")
public class LoginController {

    @Autowired
    private ILoginInfoService loginInfoService;
    @PostMapping
    public AjaxResult login(@RequestBody Map<String,String> map){
        String username = map.get("username");
        String password = map.get("password");
        try {
            //登录的逻辑
            return  loginInfoService.login(username,password);
        } catch (Exception e) {
            e.printStackTrace();
            return  AjaxResult.me().setMessage(e.getMessage());
        }

    }

}
